package com.itheima.prize.commons.db.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.prize.commons.db.entity.CardUserHit;
import com.itheima.prize.commons.db.entity.ViewCardUserHit;
import com.itheima.prize.commons.db.mapper.CardUserHitMapper;
import com.itheima.prize.commons.db.mapper.CardUserMapper;
import com.itheima.prize.commons.db.service.ViewCardUserHitService;
import com.itheima.prize.commons.db.mapper.ViewCardUserHitMapper;
import com.itheima.prize.commons.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author shawn
* @description 针对表【view_card_user_hit】的数据库操作Service实现
* @createDate 2023-12-26 11:58:48
*/
@Service
public class ViewCardUserHitServiceImpl extends ServiceImpl<ViewCardUserHitMapper, ViewCardUserHit>
    implements ViewCardUserHitService{
@Autowired
private CardUserHitMapper cardUserHitMapper;
@Autowired
private ViewCardUserHitMapper viewCardUserHitMapper;
    @Override
    public List<CardUserHit> getByUserId(Integer id) {
        LambdaQueryWrapper<CardUserHit> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(CardUserHit::getUserid,id);
        List<CardUserHit> cardUserHits = cardUserHitMapper.selectList(wrapper);
        return cardUserHits;
    }

    @Override
    public Page<ViewCardUserHit> getByUserIdlimit(int curpage, int limit, Integer id) {
        Page<ViewCardUserHit> page=new Page<>(curpage,limit);
        LambdaQueryWrapper<ViewCardUserHit> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(ViewCardUserHit::getUserid,id);
        Page<ViewCardUserHit> viewCardUserHitPage = viewCardUserHitMapper.selectPage(page, wrapper);
        return viewCardUserHitPage;
    }

    @Override
    public PageBean<ViewCardUserHit> pageViewCardUserHit(int gameid, int curpage, int limit) {
        Page<ViewCardUserHit> page=new Page<>(curpage,limit);
        LambdaQueryWrapper<ViewCardUserHit> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(ViewCardUserHit::getGameid,gameid);
        Page<ViewCardUserHit> page1 = viewCardUserHitMapper.selectPage(page, wrapper);
        PageBean<ViewCardUserHit> viewCardUserHitPageBean=new PageBean<>(page1);
        return viewCardUserHitPageBean;
    }
}




